/*
 * Copyright (C) 2018 guomw.Inc. All rights reserved.
 * 项目名称： report-manage
 * 文件名称： UserGeneTestingRepository.java
 * Date：18-11-6 下午3:00
 * Author: guomw
 */

package com.guomw.report.service.repository;

import com.guomw.report.service.entity.UserGeneTesting;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author guomw
 * @date 2018/11/6
 */
@Repository
public interface UserGeneTestingRepository extends JpaRepository<UserGeneTesting, String>, JpaSpecificationExecutor<UserGeneTesting> {


    @Transactional
    @Modifying
    @Query("update UserGeneTesting  u set u.status=?2 where u.barCode=?1")
    Integer updateStatus(String code, int status);

//    @Transactional
//    @Modifying
//    @Query("update UserGeneTesting  u set u.mobile=?2,u.keywords=?3,u.reportUrl=?4,u.status=?5 where u.barCode=?1")
//    Integer updateReportUrl(String code, String mobile, String keywords, String reportUrl, int status);


    @Transactional
    @Modifying
    @Query("update UserGeneTesting  u set u.reportToken=?2 where u.barCode=?1")
    Integer updateToken(String code, String token);


    @Transactional
    @Modifying
    @Query("update UserGeneTesting  u set u.mobile=?2,u.keywords=?3,u.GCode=?4,u.MCode=?5,u.chain=?6,u.chained=?7 where u.barCode=?1")
    Integer updateChained(String code, String mobile, String keywords, String GCode, String MCode, String chain, int chained);

}
